package com.crm.crm.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.crm.crm.domain.Dept;
import com.crm.crm.domain.SysUser;
import org.apache.ibatis.annotations.Select;
import org.springframework.data.repository.query.Param;

import java.util.List;


public interface DeptMapper extends BaseMapper<SysUser> {
    @Select("select user_name as owner from sys_user where user_id=#{userId}")
    String getOwner(Integer userId);


//查询部门所有信息，用于部门树构建
    List<Dept> selectAllDepts();


    /**
     * 查询指定父部门下的所有子部门
     */
    List<Dept> selectSubDeptsByParentId(Long parentId);

    /**
     * 根据部门 ID 列表查询所有员工
     */
    List<SysUser> selectAllUsersByDeptIds(@Param("deptIds") List<Long> deptIds);
    @Select("select * from sys_dept where dept_id = #{deptId}")
    Dept selectByDeptId(Long deptId);
}
